package exam.test.controller;

import exam.test.Pojo.SpeakerStatus;
import exam.test.mapper.SpeakerStatusMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/speaker")
public class SpeakerStatusController {

    @Autowired
    private SpeakerStatusMapper statusMapper;

    /*@PostMapping("/{speakerId}/status")
    public void updateStatus(@PathVariable Integer speakerId, @RequestBody SpeakerStatus status) {
        statusMapper.insertStatus(status);
    }

     */
    @PostMapping("/{speakerId}/status")
    public ResponseEntity<Void> updateStatus(@PathVariable Integer speakerId, @RequestBody SpeakerStatus status) {
        statusMapper.insertStatus(status);
        return ResponseEntity.ok().build();
    }

    @GetMapping("/{speakerId}/history")
    public List<SpeakerStatus> getHistory(@PathVariable Integer speakerId) {
        return statusMapper.getHistoryBySpeakerId(speakerId);
    }
}
